package org.dromara.common.core.utils;

import org.dromara.common.core.enums.TimeSqlServerEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TimeUtil {
   private static final Logger log = LoggerFactory.getLogger(TimeUtil.class);

   public static String buildTime(Integer timeCode, String startTime, String endTime) {
      log.info("[TimeUtil][buildTime]enter, timeCode:{}, startTime:{}, endTime:{}", new Object[]{timeCode, startTime, endTime});
      String result = null;
      if (timeCode != null && timeCode == 6) {
         result = TimeSqlServerEnum.buildDateSql(startTime, endTime);
      } else {
         result = TimeSqlServerEnum.buildDateSqlByCode(timeCode);
      }

      log.info("[TimeUtil][buildTime]result:{}, timeCode:{}, startTime:{}, endTime:{}", new Object[]{result, timeCode, startTime, endTime});
      return result;
   }
}
